package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class FilmPage extends AnyPage{

	public FilmPage(PageManager pages) {
		super(pages);
	}

	@FindBy (xpath = "//div[@class='maininfo_full']//h2")
	private WebElement filmInfo;
	
	@FindBy (xpath = "//img[@title='Remove']")
	private WebElement removelButton;
	

	
	public String getFilmInfo(){
		return filmInfo.getText();
	}
	
	public MainPage removeFilm(){
		removelButton.click();
	    wait.until(alertIsPresent()).accept();
		return pages.mainPage;
	}
	
	
	public FilmPage ensurePageLoaded() {
		super.ensurePageLoaded();
		wait.until(presenceOfElementLocated(By.id("movie")));
		return this;
	}
}
